package com.openspring.framework.util;

import java.sql.ResultSet;
import java.sql.SQLException;

public class NumberUtils {

	public static Integer getInteger (ResultSet rs, String column) throws SQLException {
		Integer value = rs.getInt(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Integer getInteger (ResultSet rs, int columnIndex) throws SQLException {
		Integer value = rs.getInt(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Long getLong (ResultSet rs, String column) throws SQLException {
		Long value = rs.getLong(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Long getLong (ResultSet rs, int columnIndex) throws SQLException {
		Long value = rs.getLong(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Short getShort (ResultSet rs, String column) throws SQLException {
		Short value = rs.getShort(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Short getShort (ResultSet rs, int columnIndex) throws SQLException {
		Short value = rs.getShort(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Double getDouble (ResultSet rs, String column) throws SQLException {
		Double value = rs.getDouble(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Double getDouble (ResultSet rs, int columnIndex) throws SQLException {
		Double value = rs.getDouble(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Float getFloat (ResultSet rs, String column) throws SQLException {
		Float value = rs.getFloat(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Float getFloat (ResultSet rs, int columnIndex) throws SQLException {
		Float value = rs.getFloat(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Byte getByte (ResultSet rs, String column) throws SQLException {
		Byte value = rs.getByte(column);
		if(rs.wasNull())
			value = null;
		return value;
	}
	
	public static Byte getByte (ResultSet rs, int columnIndex) throws SQLException {
		Byte value = rs.getByte(columnIndex);
		if(rs.wasNull())
			value = null;
		return value;
	}
}
